package cn.biplam.front.callback;

import cn.biplam.common.tools.TOOLS;
import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.common.wrapper.Result;
import cn.biplam.common.wrapper.UserInfo;
import cn.biplam.front.html.base.HtmlWindow;
import cn.biplam.front.html.base.Const.Align_Type;
import cn.biplam.front.html.base.Const.Length_Unit;
import cn.biplam.front.template.base.Text;

/**
 * 表格单元格绑定—字段居中对齐绑定器
 * @author XiaoRuxing Aug 7, 20093:23:11 PM
 * @version 1.0
 */
public class FieldAlignCenterCallback implements CallBack{

	private String sFieldName;
	
	/**
	 * 创建字段居中对齐绑定器
	 * @param sFieldName 绑定字段名
	 */
	public FieldAlignCenterCallback(String sFieldName){
		this.sFieldName = sFieldName;
	}
	
	/**
	 * 创建字段居中对齐绑定器
	 * @param sFieldName 绑定字段名
	 */
	public FieldAlignCenterCallback(Object sFieldName){
		this.sFieldName = String.valueOf(sFieldName);
	}
	
	public HtmlWindow[] getGroup(Result data, String homeUrl, UserInfo user)
	throws ErrorMessage {
		String reuleCount = data.getString(sFieldName);
		HtmlWindow[] total = new HtmlWindow[1];
		Text text=new Text(reuleCount);
		HtmlWindow typeDesc=text.get();
		typeDesc.setLength(TOOLS.getPxLength(text.getLength()));
		typeDesc.setStyleWidth("80", Length_Unit.percent);
		typeDesc.setTextAlign(Align_Type.center);
		total[0] = typeDesc ;
		return total;
	}
}
